using sockets, system;

const path = "server_socket";

client = loop with
  // Keep reading requests from stdin.
  loop = loop if ~null s && ~request s when
    fputs "client> " stdout; s = fgets stdin;
  end;
  loop = puts "client is exiting" $$ () otherwise;
  request s::string = s=="quit\n" when
    fd = socket AF_UNIX SOCK_STREAM 0;
    connect fd (sockaddr path);
    // Send the request to the server.
    fp = fdopen fd "r+"; fputs s fp;
    // Get the reply.
    s = fgets fp;
  end;
end;

client;

